package org.itworks.biodev.model;

public class ProductSale {
	private float price;
	private Integer quantity;
	private Product product;
	private int productId;
	private int saleId;
	private Sale sale;
	
	public float getPrice() {
		return price;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	public Integer getQuantity() {
		return quantity;
	}
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}
	public Sale getSale() throws Exception {
		if(sale == null) {
			sale = SaleTable.getInstance().findSaleFromProductSale(this);
		}
		return sale;
	}
	public void setSale(Sale sale) {
		this.sale = sale;
		this.saleId = sale.getId();
	}
	public Product getProduct() throws Exception {
		if(product == null) {
			product = ProductSaleTable.getInstance().findProductFromProductSale(this);
		}
		return product;
	}
	public void setProduct(Product xProduct) {
		this.product = xProduct;
		this.productId = product.getId();
	}
	public int getProductId() {
		return productId;
	}
	public void setProductId(int productId) {
		this.productId = productId;
	}
	public int getSaleId() {
		return saleId;
	}
	public void setSaleId(int orderId) {
		this.saleId = orderId;
	}
}
